<%@page contentType="text/html;charset=UTF-8" language = "java"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<html>
	<head>
		<title>JWiki 管理</title>
		</head>
		<body bgcolor="white">
		<center>
			<div align = "center">
				 <h2><font size = "4">管理员主页</font></h2>
			</div>
			<br>
			<table align="center">
			<tr align="center">
			<td><a href="admin.do?page=main">管理主页</a></td>
			<td><a href="admin.do?page=useradmin">管理用户</a></td>
			<td><a href="admin.do?page=itemadmin">管理词条</a></td>			
			</tr>
			</table>
			<hr>
			<font color = 'blue'>wiki首页选择</font>
		</center>				
			<br>
			<form name = "form1" method = "post" action = "admin.do?page=main&action=select">
		<c:if test="${aftersel == 1}">
		<c:set var="aftersel" value="${aftersel-1}" scope="session"/>
			<p align = "center">已经选择的词条是：</p>
			<table width = "50%" border = "0" align = "center" bordercolor = "white" bgcolor = "white" cellpadding = "0">				
				<tr bgcolor = "grey" align = "center">
					<td>序号</td>
					<td>名称</td>
					<td>内容</td>
					<td>类型</td>
				</tr>
				<tr bgcolor = "red" align = "center">
					<td><c:out value="${selected.itemId}"/></td>
					<td><c:out value="${selected.title}"/></td>
					<td><c:out value="${fn:substring(item.content, 0, 30)}..." /></td>
					<td><c:out value="${selected.type}"/></td>
				</tr>
			</table>
			<p align = "center">现有词条如下：</p>
		</c:if>
			<table width = "50%" border = "0" align = "center" bordercolor = "white" bgcolor = "white" cellpadding = "0">
				<tr bgcolor = "#CCFF22" align = "center">
					<td>选中</td>
					<td>名称</td>
					<td>内容</td>
					<td>类型</td>
				</tr>
				<c:forEach items="${itemslist}" var="item">
					<tr bgcolor = "<c:choose><c:when test="${item.type==1}">#D3D3D3</c:when><c:when test="${item.type==2}">#ADD8E6</c:when><c:when test="${item.type==3}">#20B2AA</c:when><c:when test="${item.type==4}">#BC8F8F</c:when><c:when test="${item.type==5}">#D8BFD8</c:when><c:otherwise>#D2B48C</c:otherwise></c:choose>" align = "center">
						<td><input type = "radio" name = "beselected" value =<c:out value="${item.itemId}"/> ></td>
						<td><c:out value="${item.title}"/></td>
						<td><c:out value="${fn:substring(item.content, 0, 30)}..." /></td>
						<td>
						<c:choose>
						<c:when test="${item.type==1}">目录</c:when>
						<c:when test="${item.type==2}">词条</c:when>
						<c:when test="${item.type==3}">文件</c:when>
						<c:otherwise>其他</c:otherwise>
						</c:choose>
						</td>
					</tr>
				</c:forEach>		
	</table>	
	<br>
	<br>
	<center>
		<br />
		<tr>
			<td>
					<input type = "submit" value = "提交选择">
			</td>
		</tr>
	</center>
				</form>
    </body>
</html>